package gui;

import eventbus.PageEventBus;

import javax.swing.*;
import java.awt.event.ActionListener;

public abstract class SubPanel extends JPanel {
    private static final int WIDTH = 1000;
    private static final int HEIGHT = 601;
    static ActionListener backListener;

    public SubPanel() {
        setLayout(null);
        setSize(WIDTH, HEIGHT);
        PageEventBus.subscribe(this);
        JButton backBtn = new JButton(new ImageIcon("./res/imgs/back.png"));
        backBtn.setBounds(10, 10, 50, 50);
        backBtn.addActionListener(backListener);
        add(backBtn);

    }

    //注册返回按钮监听器
    public static void registerBackBtnListener(ActionListener listener) {
        backListener = listener;
    }
}
